/*
 * 文件名：CrossingServiceImpl.java	 
 * 时     间：下午8:15:43
 * 作     者：Administrator       
 * 版     权： 2012-2022 湖南智软网络科技, 公司保留所有权利.
 * 联     系：http://www.073586.com/
 */
package com.local.service.impl;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.cloud.threads.UpDateCrossingRunble;
import com.cloud.threads.UploadCrossingAssignEquipmentRunble;
import com.cloud.threads.UploadCrossingAssignStationRunble;
import com.cloud.threads.UploadCrossingRunble;
import com.cz073586.common.tcp.TcpInterfaceManger;
import com.cz073586.tools.util.ThreadPoolUtil;
import com.cz073586.tools.util.Tools;
import com.local.dao.mapers.CrossingMapper;
import com.local.dao.mapers.CrossingToEquipmentMapper;
import com.local.dao.mapers.CrossingToStationMapper;
import com.local.dao.mapers.LocalEquipmentMapper;
import com.local.dao.mapers.LocalStationMapper;
import com.local.entity.vo.StationAndCrossionVo;
import com.local.entity.vo.TakePhotoParamVo;
import com.local.manager.cfgManager.CloudConfigManager;
import com.local.manager.thread.OpenCateThread;
import com.local.manager.thread.TakePhotoThread;
import com.local.model.Crossing;
import com.local.model.CrossingExample;
import com.local.model.CrossingToEquipment;
import com.local.model.CrossingToEquipmentExample;
import com.local.model.CrossingToStation;
import com.local.model.CrossingToStationExample;
import com.local.model.LocalEquipment;
import com.local.model.LocalEquipmentExample;
import com.local.model.LocalStation;
import com.local.model.LocalStationExample;
import com.local.page.CrossingPageInfo;
import com.local.service.face.CrossingService;
import com.local.service.face.LogService;
import com.local.service.face.StreamingMediaService;
import com.qianhai.common.dao.face.BaseMapper;
import com.qianhai.common.entity.PageInfo;
import com.qianhai.common.exception.BaseException;
import com.qianhai.common.service.impl.BaseServiceImpl;
import com.qianhai.common.utils.UUIDGenerateUtil;

/**
 * 类描述:这里是类描述
 * 
 * @ClassName: CrossingServiceImpl
 * @author Administrator
 * @date 2015年10月6日 下午8:15:43
 */
@Service
public class CrossingServiceImpl extends
		BaseServiceImpl<Object, Object, String> implements CrossingService
{
	
	@Autowired
	private CrossingMapper crossinMapper;
	
	@Autowired
	private CrossingToEquipmentMapper crosToEquiMapper;
	
	@Autowired
	private CrossingToStationMapper croToSationMapper;
	@Autowired
	private StreamingMediaService streamService;
	
	@Autowired
	private LocalEquipmentMapper equipmentMapper;
	@Autowired
	private LocalStationMapper sationMapper;
	
	@Autowired
	private LogService logService;
	
	/**
	 * 
	 * 方法描述： 通过名字获取
	 * 
	 * @Title: getCrossinByName
	 * @param @param name
	 * @param @return
	 * @return List<Crossing>
	 * @user lyf 2015年10月6日
	 * @throws
	 */
	private List<Crossing> getCrossinByName(String name)
	{
		CrossingExample condition = new CrossingExample();
		condition.or().andNameEqualTo(name);
		List<Crossing> list = crossinMapper.selectByCondition(condition);
		return list;
	}
	
	/**
	 * 
	 * 方法描述： 进程名称
	 * 
	 * @Title: getCrossinProssceId
	 * @param @param ProssceId
	 * @param @return
	 * @return List<Crossing>
	 * @user lyf 2015年10月6日
	 * @throws
	 */
	private List<Crossing> getCrossinProssceId(String ProssceId)
	{
		CrossingExample condition = new CrossingExample();
		condition.or().andProcessIdEqualTo(ProssceId);
		List<Crossing> list = crossinMapper.selectByCondition(condition);
		return list;
	}
	
	/**
	 * 
	 * 方法描述： 流媒文件名
	 * 
	 * @Title: getCrossinStream
	 * @param @param Stream
	 * @param @return
	 * @return List<Crossing>
	 * @user lyf 2015年10月6日
	 * @throws
	 */
	private List<Crossing> getCrossinStream(String Stream)
	{
		CrossingExample condition = new CrossingExample();
		condition.or().andStreamEqualTo(Stream);
		List<Crossing> list = crossinMapper.selectByCondition(condition);
		return list;
	}
	
	@Override
	public Integer addCrossin(Crossing crossing) throws BaseException
	{
		try
		{
			if (Tools.isEmpty(crossing.getName()))
			{
				throw new BaseException("50000-00001-00025");
			}
			
			List<Crossing> list = getCrossinByName(crossing.getName());
			if (!list.isEmpty())
			{
				throw new BaseException("50000-00001-00026");
			}
			
			crossing.setUuid(UUIDGenerateUtil.generate());
			crossinMapper.insertSelective(crossing);
			
			if (CloudConfigManager.instance().isOpen())
			{
				UploadCrossingRunble upload = new UploadCrossingRunble(
						crossing, logService);
				ThreadPoolUtil.instance().execute(upload);
			}
		} catch (Throwable t)
		{
			log.error(t.getMessage(), t);
			throw new BaseException(t.getMessage());
		}
		return null;
	}
	
	@Override
	public Integer editCrossinById(Crossing crossing) throws BaseException
	{
		try
		{
			if (Tools.isEmpty(crossing.getUuid()))
			{
				throw new BaseException("50000-00001-00001");
			}
			
			if (!Tools.isEmpty(crossing.getName())
					&& !crossinMapper.selectByPrimaryKey(crossing.getUuid())
							.getName().equalsIgnoreCase(crossing.getName()))
			{
				List<Crossing> list = getCrossinByName(crossing.getName());
				if (!list.isEmpty())
				{
					throw new BaseException("50000-00001-00026");
				}
			}
			
			// 2016-7-24 路口控制汇总,设置主控制器相机编码
			if (!Tools.isEmpty(crossing.getProcessId()))
			{
				List<LocalEquipment> eqLists = queryEquimentByCrossionId(crossing
						.getProcessId());
				if (!Tools.isEmpty(eqLists) && !eqLists.isEmpty())
				{
					crossing.setEquipmentViewStream(eqLists.get(0)
							.getCameraNo());
				}
			}else
			{
				//取消汇总
				crossing.setEquipmentViewStream("");
			}
			// 2016-7-24 路口控制汇总
			
			crossinMapper.updateByPrimaryKeySelective(crossing);
			if (CloudConfigManager.instance().isOpen())
			{
				UpDateCrossingRunble upload = new UpDateCrossingRunble(
						crossing, logService);
				ThreadPoolUtil.instance().execute(upload);
			}
		} catch (Throwable t)
		{
			log.error(t.getMessage(), t);
			throw new BaseException(t.getMessage());
		}
		return null;
	}
	
	@Override
	public Crossing getCrossinByid(String uuid)
	{
		try
		{
			return crossinMapper.selectByPrimaryKey(uuid);
		} catch (Throwable t)
		{
			log.error(t.getMessage(), t);
			throw new BaseException(t.getMessage());
		}
		
	}
	
	@Override
	public Integer delCrossinById(String uuid) throws BaseException
	{
		try
		{
			// 同时删除关联,设备和岗亭
			CrossingToEquipmentExample eqEx = new CrossingToEquipmentExample();
			eqEx.or().andCrossingUuidEqualTo(uuid);
			crosToEquiMapper.deleteByCondition(eqEx);
			
			// 岗亭
			CrossingToStationExample condition = new CrossingToStationExample();
			condition.or().andCrossingUuidEqualTo(uuid);
			croToSationMapper.deleteByCondition(condition);
			
			crossinMapper.deleteByPrimaryKey(uuid);
		} catch (Throwable t)
		{
			log.error(t.getMessage(), t);
			throw new BaseException(t.getMessage());
		}
		return null;
	}
	
	@Override
	public void queryCrossinByPage(CrossingPageInfo page)
	{
		List<Crossing> list = crossinMapper.queryByPage(page);
		int count = crossinMapper.countAllByPage(page);
		
		for (Crossing cs : list)
		{
			// 关联汇总路口名,此时 processId 等于路口uuid
			if (!Tools.isEmpty(cs.getProcessId()))
			{
				Crossing crsInfo = crossinMapper.selectByPrimaryKey(cs
						.getProcessId());
				if (!Tools.isEmpty(crsInfo))
				{
					cs.setCollectName(crsInfo.getName());
				}
			}// end if
		}
		
		if (!Tools.isEmpty(page.getStationUuid()))
		{
			
			for (Crossing cs : list)
			{
				// 不明白是什么意思
				cs.setChecked(false);
				CrossingToStationExample condition = new CrossingToStationExample();
				condition.or().andStationUuidEqualTo(page.getStationUuid());
				List<CrossingToStation> ctLs = croToSationMapper
						.selectByCondition(condition);
				for (CrossingToStation cssts : ctLs)
				{
					if (cs.getUuid().equalsIgnoreCase(cssts.getCrossingUuid()))
					{
						cs.setChecked(true);
					}
				}
			}// end for
		}
		page.setData(list);
		page.setTotalRecords(count);
	}
	
	@Override
	public Integer createVidoConnect(String crossinId) throws BaseException
	{
		try
		{
			Crossing crossingInfo = crossinMapper.selectByPrimaryKey(crossinId);
			
			if (Tools.isEmpty(crossingInfo.getEquipmentViewStream()))
			{
				throw new BaseException("50000-00001-00028");
			}
			
			if (Tools.isEmpty(crossingInfo.getViewUrl()))
			{
				throw new BaseException("50000-00001-00029");
			}
			
			if (Tools.isEmpty(crossingInfo.getStream()))
			{
				throw new BaseException("50000-00001-000230");
			}
			
			streamService.createConnect(crossingInfo.getProcessId(),
					crossingInfo.getEquipmentViewStream(),
					crossingInfo.getResolution(), crossingInfo.getViewUrl()
							+ "/" + crossingInfo.getStream(), false);
		} catch (Throwable t)
		{
			log.error(t.getMessage(), t);
			throw new BaseException(t.getMessage());
		}
		return null;
	}
	
	@Override
	public List<Crossing> queryCrossinBySationId(String sationId)
	{
		try
		{
			CrossingToStationExample mapEx = new CrossingToStationExample();
			mapEx.or().andStationUuidEqualTo(sationId);
			List<CrossingToStation> mapList = croToSationMapper
					.selectByCondition(mapEx);
			if (!mapList.isEmpty())
			{
				List<String> values = new ArrayList<String>();
				
				for (CrossingToStation map : mapList)
				{
					values.add(map.getCrossingUuid());
				}
				
				CrossingExample crosEx = new CrossingExample();
				crosEx.or().andUuidIn(values);
				return crossinMapper.selectByCondition(crosEx);
			}
		} catch (Throwable t)
		{
			log.error(t.getMessage(), t);
			throw new BaseException(t.getMessage());
		}
		return null;
	}
	
	@Override
	public List<LocalEquipment> queryEquimentByCrossionId(String crssionId)
	{
		try
		{
			CrossingToEquipmentExample mapEx = new CrossingToEquipmentExample();
			mapEx.or().andCrossingUuidEqualTo(crssionId);
			List<CrossingToEquipment> listMap = crosToEquiMapper
					.selectByCondition(mapEx);
			
			if (!listMap.isEmpty())
			{
				List<String> values = new ArrayList<String>();
				
				for (CrossingToEquipment equMent : listMap)
				{
					values.add(equMent.getEquipmentUuid());
				}
				
				LocalEquipmentExample eqEx = new LocalEquipmentExample();
				eqEx.or().andEquipmentUuidIn(values);
				return equipmentMapper.selectByCondition(eqEx);
			}
			
		} catch (Throwable t)
		{
			log.error(t.getMessage(), t);
			throw new BaseException(t.getMessage());
		}
		return null;
	}
	
	public List<LocalEquipment> queryNotBindedEquimentList(String uuid)
	{
		PageInfo<CrossingToEquipment> page = new PageInfo<CrossingToEquipment>();
		page.setPageSize(Integer.MAX_VALUE);
		List<CrossingToEquipment> listMap = crosToEquiMapper.queryByPage(page);
		
		List<LocalEquipment> resustList;
		List<LocalEquipment> areadyExistList = queryEquimentByCrossionId(uuid);
		
		if (!listMap.isEmpty())
		{
			List<String> values = new ArrayList<String>();
			for (CrossingToEquipment croToEqPojo : listMap)
			{
				values.add(croToEqPojo.getEquipmentUuid());
			}
			
			LocalEquipmentExample eqEx = new LocalEquipmentExample();
			eqEx.or().andEquipmentUuidNotIn(values);
			resustList = equipmentMapper.selectByCondition(eqEx);
		} else
		{
			PageInfo<LocalEquipment> eqPageInfo = new PageInfo<LocalEquipment>();
			eqPageInfo.setPageSize(Integer.MAX_VALUE);
			resustList = equipmentMapper.queryByPage(eqPageInfo);
			
		}
		
		if (null != areadyExistList && !areadyExistList.isEmpty())
		{
			resustList.addAll(areadyExistList);
		}
		return resustList;
	}
	
	@Override
	public Integer stationAssignCrossion(List<CrossingToStation> list)
			throws BaseException
	{
		try
		{
			if (null != list && !list.isEmpty())
			{
				CrossingToStationExample condition = new CrossingToStationExample();
				condition.or().andCrossingUuidEqualTo(
						list.get(0).getCrossingUuid());
				croToSationMapper.deleteByCondition(condition);
			}
			
			for (CrossingToStation cMts : list)
			{
				croToSationMapper.insertSelective(cMts);
			}
			
			if (CloudConfigManager.instance().isOpen())
			{
				UploadCrossingAssignStationRunble upload = new UploadCrossingAssignStationRunble(
						list, logService);
				ThreadPoolUtil.instance().execute(upload);
			}
		} catch (Throwable t)
		{
			log.error(t.getMessage(), t);
			throw new BaseException(t.getMessage());
		}
		return null;
	}
	
	@Override
	public Integer crossionAssignEquipment(List<CrossingToEquipment> list)
			throws BaseException
	{
		try
		{
			if (null != list && !list.isEmpty())
			{
				CrossingToEquipmentExample condition = new CrossingToEquipmentExample();
				condition.or().andCrossingUuidEqualTo(
						list.get(0).getCrossingUuid());
				crosToEquiMapper.deleteByCondition(condition);
			}
			
			for (CrossingToEquipment mapToEq : list)
			{
				if (Tools.isEmpty(mapToEq.getStatus()))
				{
					mapToEq.setStatus(1);
				}
				
				if (!Tools.isEmpty(mapToEq.getEquipmentUuid()))
				{
					crosToEquiMapper.insertSelective(mapToEq);
				}
				if (!Tools.isEmpty(mapToEq.getCrossingUuid()))
				{
					CrossingExample condtion = new CrossingExample();
					condtion.or().andUuidEqualTo(mapToEq.getCrossingUuid());
					Crossing cs = crossinMapper.selectByCondition(condtion)
							.get(0);
					
					if (!Tools.isEmpty(cs))
					{
						LocalEquipment localequip = equipmentMapper
								.selectByPrimaryKey(mapToEq.getEquipmentUuid());
						if (!Tools.isEmpty(localequip))
						{
							localequip.setInstallEffect(cs.getStatus()
									.toString());
							localequip.setInstallPosition(cs.getName());
							equipmentMapper
									.updateByPrimaryKeySelective(localequip);
						}
					}
				}
			}
			
			if (CloudConfigManager.instance().isOpen())
			{
				UploadCrossingAssignEquipmentRunble upload = new UploadCrossingAssignEquipmentRunble(
						list, logService);
				ThreadPoolUtil.instance().execute(upload);
			}
		} catch (Throwable t)
		{
			log.error(t.getMessage(), t);
			throw new BaseException(t.getMessage());
		}
		return null;
	}
	
	@SuppressWarnings("static-access")
	@Override
	public void openGATE(String crossinId, String stationId)
	{
		try
		{
			
			// 检查控制汇总开关 2016-71-24
			Crossing crsInfo = crossinMapper.selectByPrimaryKey(crossinId);
			if (Tools.isEmpty(crsInfo))
			{
				throw new BaseException("50000-00001-00035");
			}
			
			if (!Tools.isEmpty(crsInfo.getProcessId()))
			{
				// 开闸控制为主相机
				crossinId = crsInfo.getProcessId();
			}
			// 检查控制汇总开关 2016-71-24
			
			CrossingToEquipmentExample condition = new CrossingToEquipmentExample();
			condition.or().andCrossingUuidEqualTo(crossinId);
			// .andStatusNotEqualTo(0);
			// condition.or().andCrossingUuidEqualTo(crossinId)
			// .andStatusNotEqualTo(0);
			List<CrossingToEquipment> list = crosToEquiMapper
					.selectByCondition(condition);
			if (list.isEmpty())
			{
				throw new BaseException("50000-00001-00035");
			}
			
			CrossingToEquipment mpEqo = list.get(0);
			LocalEquipment eqment = equipmentMapper.selectByPrimaryKey(mpEqo
					.getEquipmentUuid());
			
			if (Tools.isEmpty(eqment))
			{
				throw new BaseException("50000-00001-00036");
			}
			
			// 判断是否是火眼相机,2016-5-18
			LocalEquipment equmentInfo = equipmentMapper
					.selectByPrimaryKey(list.get(0).getEquipmentUuid());
			if (!Tools.isEmpty(equmentInfo)
					&& ("1").equals(equmentInfo.getAttr1()))
			{
				try
				{
					TcpInterfaceManger.instance().ioCtrlOpenDoor(
							equmentInfo.getCameraIp(),
							Integer.parseInt(equmentInfo.getAttr2()), 1000, 0,
							2, 500);
					
					return;
				} catch (Throwable e)
				{
					e.printStackTrace();
					log.error("火眼相机抓拍异常:", e);
				}
			}
			// 判断是否是火眼相机,2016-5-18
			
			// 2016-3-17 中间是否负载到岗亭
			String middleIp = null;
			if (!Tools.isEmpty(stationId))
			{
				LocalStation station = sationMapper
						.selectByPrimaryKey(stationId);
				if (!Tools.isEmpty(station)
						&& !Tools.isEmpty(station.getStatus())
						&& station.getStatus() == 1)
				{
					middleIp = station.getEquipmentViewStream();
				}
			}
			// 开闸
			OpenCateThread open = new OpenCateThread(eqment.getCameraNo(),
					middleIp);
			ThreadPoolUtil.instance().execute(open);
		} catch (Throwable t)
		{
			log.error(t.getMessage(), t);
			throw new BaseException(t.getMessage());
		}
		
	}
	
	@Override
	public BaseMapper<Object, Object, String> getMapper()
	{
		// TODO Auto-generated method stub
		return null;
	}
	
	@Override
	public List<Crossing> queryCrossingByEquimentNo(String equimentNo)
	{
		
		// 查询设备
		LocalEquipmentExample equimentEx = new LocalEquipmentExample();
		equimentEx.or().andCameraNoEqualTo(equimentNo);
		List<LocalEquipment> listEq = equipmentMapper
				.selectByCondition(equimentEx);
		
		if (listEq.isEmpty())
		{
			return new ArrayList<Crossing>();
		}
		
		// 获取设备与路口映射
		CrossingToEquipmentExample exCtoeq = new CrossingToEquipmentExample();
		exCtoeq.or().andEquipmentUuidEqualTo(listEq.get(0).getEquipmentUuid());
		List<CrossingToEquipment> croEquipmentMapList = crosToEquiMapper
				.selectByCondition(exCtoeq);
		
		if (!croEquipmentMapList.isEmpty())
		{
			List<String> cossinUUidList = new ArrayList<String>();
			for (CrossingToEquipment cequimnetMap : croEquipmentMapList)
			{
				cossinUUidList.add(cequimnetMap.getCrossingUuid());
			}
			
			CrossingExample crossinEx = new CrossingExample();
			crossinEx.or().andUuidIn(cossinUUidList);
			return crossinMapper.selectByCondition(crossinEx);
		}
		
		return new ArrayList<Crossing>();
	}
	
	@Override
	public List<LocalStation> queryStaionsByCrosList(List<Crossing> list)
	{
		if (list.isEmpty())
		{
			return new ArrayList<LocalStation>();
		}
		
		List<String> crossinIdList = new ArrayList<String>();
		
		for (Crossing crossing : list)
		{
			crossinIdList.add(crossing.getUuid());
		}
		
		CrossingToStationExample cStationMapEx = new CrossingToStationExample();
		cStationMapEx.or().andCrossingUuidIn(crossinIdList);
		List<CrossingToStation> listMaps = croToSationMapper
				.selectByCondition(cStationMapEx);
		
		if (listMaps.isEmpty())
		{
			return new ArrayList<LocalStation>();
		}
		
		List<String> stationIdLists = new ArrayList<String>();
		for (CrossingToStation mapPojo : listMaps)
		{
			stationIdLists.add(mapPojo.getStationUuid());
		}
		
		LocalStationExample condition = new LocalStationExample();
		condition.or().andStationUuidIn(stationIdLists);
		return sationMapper.selectByCondition(condition);
		
	}
	
	@SuppressWarnings("static-access")
	@Override
	public void takePhoto(TakePhotoParamVo vo)
	{
		// 判定是否是火眼相机，如果是火眼相机则无需执行为科相机 2016-5-18
		if (!Tools.isEmpty(vo.getEqumentNo()))
		{
			LocalEquipmentExample ex = new LocalEquipmentExample();
			ex.or().andCameraNoEqualTo(vo.getEqumentNo().trim());
			List<LocalEquipment> list = equipmentMapper.selectByCondition(ex);
			if (!Tools.isEmpty(list) && !list.isEmpty()
					&& "1".equals(list.get(0).getAttr1()))
			{
				try
				{
					TcpInterfaceManger.instance().trigger(
							list.get(0).getCameraIp(),
							Integer.parseInt(list.get(0).getAttr2()), 1000);
					
				} catch (Throwable e)
				{
					e.printStackTrace();
					log.error("火眼相机抓拍异常:", e);
				}
				return;
			}
		}
		// ----end 判定是否是火眼相机，如果是火眼相机则无需执行为科相机 2016-5-18
		
		if (!Tools.isEmpty(vo.getEqumentNo()))
		{
			String midSoftIp = null;
			// 添加是否启用岗亭负载，如果启用负载功能则制定ip 2016-3-17
			if (!Tools.isEmpty(vo.getStationUuid()))
			{
				LocalStation station = sationMapper.selectByPrimaryKey(vo
						.getStationUuid());
				// station.getStatus() 1 启用负载功能 station.getEquipmentViewStream()
				// = 中间件ip
				if (!Tools.isEmpty(station)
						&& !Tools.isEmpty(station.getStatus())
						&& station.getStatus() == 1)
				{
					midSoftIp = station.getEquipmentViewStream();
				}
			}
			// end 2016-3-7
			TakePhotoThread takPhoto = new TakePhotoThread(vo.getEqumentNo(),
					midSoftIp);
			ThreadPoolUtil.instance().execute(takPhoto);
		}
	}
	
	@Override
	public void stationAndCrossion(StationAndCrossionVo sac)
			throws BaseException
	{
		// TODO Auto-generated method stub
		try
		{
			List<CrossingToStation> list = new ArrayList<CrossingToStation>();
			if (null != sac && !Tools.isEmpty(sac))
			{
				for (String crossingUuid : sac.getIds())
				{
					CrossingToStation cs = new CrossingToStation();
					cs.setCrossingUuid(crossingUuid);
					cs.setStationUuid(sac.getStationUuid());
					list.add(cs);
				}
			}
			if (!Tools.isEmpty(sac.getStationUuid()))
			{
				CrossingToStationExample condition = new CrossingToStationExample();
				condition.or().andStationUuidEqualTo(sac.getStationUuid());
				croToSationMapper.deleteByCondition(condition);
			}
			
			for (CrossingToStation cMts : list)
			{
				croToSationMapper.insertSelective(cMts);
			}
			if (CloudConfigManager.instance().isOpen())
			{
				UploadCrossingAssignStationRunble upload = new UploadCrossingAssignStationRunble(
						list, logService);
				ThreadPoolUtil.instance().execute(upload);
			}
		} catch (Throwable t)
		{
			log.error(t.getMessage(), t);
			throw new BaseException(t.getMessage());
		}
	}
	
	@Override
	public LocalStation findStationByCrosId(String crossingId)
	{
		CrossingToStationExample condition = new CrossingToStationExample();
		condition.or().andCrossingUuidEqualTo(crossingId);
		List<CrossingToStation> list = croToSationMapper
				.selectByCondition(condition);
		if (!list.isEmpty())
		{
			return sationMapper.selectByPrimaryKey(list.get(0).getStationUuid());
		}
		return null;
	}
	
}
